package com.gan.yidademo.controller.yida;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.gan.yidademo.haikang.model.dto.event.FaceCaptureDto;
import com.gan.yidademo.leave.model.StuLeave;
import org.springframework.web.bind.annotation.*;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Map;

/**
 * @author gbw
 * @date 2023/10/12
 */
@RestController
@RequestMapping("/yd")
public class YiDaController {


    /**
     * 接收学生请假后的推送信息，拿到
     *
     * @param stuLeaveMap
     * @return
     */
    @PostMapping(value = "/stu_leave", consumes = "application/x-www-form-urlencoded;charset=UTF-8")
    public String receiveData(@RequestParam Map<String, Object> stuLeaveMap) {
        System.out.println(stuLeaveMap.get("beginTime"));
        System.out.println(stuLeaveMap.get("endTime"));

        StuLeave stuLeave = BeanUtil.toBean(stuLeaveMap, StuLeave.class);
        Date beginTime = new Date((Long) stuLeaveMap.get("beginTime"));
        System.out.println(beginTime);

        System.out.println(stuLeave);

        JSONObject jsonBody = new JSONObject();
        jsonBody.put("code", "200");
        jsonBody.put("msg", "success");
        jsonBody.put("data", null);
        return jsonBody.toString();
    }
}
